﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace winForm
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            if (ofd.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
            {
                string file = ofd.FileName;
                this.textBox1.Text = file;
                string path = this.textBox1.Text;
                this.textBox3.Text += File.ReadAllText(path, Encoding.Default);
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            if (ofd.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
            {
                string file = ofd.FileName;
                this.textBox2.Text = file;
                string path = this.textBox2.Text;
                this.textBox3.Text += File.ReadAllText(path, Encoding.Default);
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            string fileName = Path.Combine(Application.StartupPath, @"Data");
            string file1 = Path.Combine(fileName, "new.txt");
            FileStream fs = File.Create(file1, 1024, FileOptions.None);
            StreamWriter sw = new StreamWriter(fs);
            sw.Write(this.textBox3.Text);
            sw.Dispose();
            this.textBox3.Text = "";
        }
    }
}
